/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dal;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author MinhDuc
 */
public class QueryExecuter {

    private Connection connect;

    public QueryExecuter() {
    }

    public int updateQuerry(String sql) {
        if (connect == null) {
            connect = ConnectDatabase.getConnection();
        }
        if (connect != null) {
            try {
                Statement stm = connect.createStatement();
                return stm.executeUpdate(sql);
            } catch (Exception ex) {
            }
        }
        return -1;
    }

    public ResultSet exeQuerry(String sql) {
        ResultSet rs = null;
        if (connect == null) {
            connect = ConnectDatabase.getConnection();
        }
        if (connect != null) {
            try {
                Statement stm = connect.createStatement();
                rs = stm.executeQuery(sql);
            } catch (Exception ex) {
            }
        }
        return rs;
    }
}
